/*
 * Copyright (C) 2009 Christoph Caks
 *
 * This file is part of GLWAK.
 *
 * GLWAK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GLWAK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with GLWAK.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * WindowsHelper.cpp
 *
 *  Created on: 01.08.2009
 *      Author: Christoph
 */

#include "windows/WindowsHelper.h"

namespace glwak {

namespace util {

WindowsHelper::WindowsHelper() {
}

WindowsHelper::~WindowsHelper() {
}

const std::string WindowsHelper::getLastError() {
	DWORD dw = GetLastError();
    LPVOID lpBuffer;

    int size = FormatMessage(
        FORMAT_MESSAGE_ALLOCATE_BUFFER |
        FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        dw,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR) &lpBuffer,
        0, NULL );

    std::ostringstream tmp;
    tmp << dw << " - " << (LPCTSTR)lpBuffer;

    LocalFree( lpBuffer );

    return tmp.str();
}

} // namespace util

} // namespace glwak
